package com.wedata.致远接口;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.wedata.HttpUtils;

public class 岗位管理 {


    public static void main(String[] args) {
        orgPosts();
    }

    private static void orgPosts(){
        JSONArray posts = HttpUtils.getList(token.hostUrl + "/rest/orgPosts/" + token.accountId + "?token=" + token.getToken());
        System.out.println(posts.size());
        for(int i=0;i<posts.size();i++){
            JSONObject post = posts.getJSONObject(i);
            System.out.println(post.getStr("typeId")+"  "+post.getStr("name")+"    "+post.getStr("id"));
            /*if(!post.getStr("code").equals("")){
                System.out.println(post);
            }*/

        }
    }
    private static void orgPostsCount(){
        String result = HttpUtils.getString(token.hostUrl + "/rest/orgPosts/count/" + token.accountId + "?token=" + token.getToken());
        System.out.println(result);
    }
    private static void createPost(){
        JSONObject body = new JSONObject();
        //body.set("id",3937920883615744090L);
        body.set("orgAccountId",token.accountId);
        body.set("code","disdr");
        body.set("name","JAVA组长2");
        body.set("description","接口调研");
        body.set("typeId",1);
        //JSONObject result = HttpUtils.sendPost(token.hostUrl + "/rest/orgPost?token=" + token.getToken(),body);
        JSONObject result = HttpUtils.sendPost(token.hostUrl + "/rest/orgPost?token=" + token.getToken(),null,body);

        System.out.println(result);
        //岗位名称重复
        //{"successMsgs":[],"errorMsgs":[{"code":"POST_REPEAT_NAME","ent":{"orgAccountId":670869647114347,"id":3733289402804881262,"name":"JAVA组长","i18nNameId":null,"code":"Z010","createTime":1712024319068,"updateTime":1712024319068,"sortId":null,"isDeleted":false,"enabled":true,"externalType":0,"status":1,"description":"接口调研","customerProperties":[],"typeId":1,"valid":true,"entityType":"Post","fullName":"JAVA组长","dataI18nCategoryName":"organization.post.name","i18nNameWithLocale":"JAVA组长","realSortId":null,"preName":""},"msgInfo":null}],"errorMsgInfos":[{"code":null,"ent":{"orgAccountId":670869647114347,"id":3733289402804881262,"name":"JAVA组长","i18nNameId":null,"code":"Z010","createTime":1712024319068,"updateTime":1712024319068,"sortId":null,"isDeleted":false,"enabled":true,"externalType":0,"status":1,"description":"接口调研","customerProperties":[],"typeId":1,"valid":true,"entityType":"Post","fullName":"JAVA组长","dataI18nCategoryName":"organization.post.name","i18nNameWithLocale":"JAVA组长","realSortId":null,"preName":""},"msgInfo":"岗位名称重复，操作失败！"}],"success":false}
        //注：code可以重复
    }
    private static void updatePost(){
        JSONObject body = new JSONObject();
        body.set("id",3937920883615744090L);
        //body.set("orgAccountId",token.accountId);
        //body.set("code","Z010");
        //body.set("name","JAVA组长2");
        body.set("description","接口调研");
        //body.set("typeId",1);
        //JSONObject result = HttpUtils.sendPost(token.hostUrl + "/rest/orgPost?token=" + token.getToken(),body);
        JSONObject result = HttpUtils.sendRequest(token.hostUrl + "/rest/orgPost?token=" + token.getToken(),null,body,"PUT");

        System.out.println(result);
        //岗位名称重复
        //{"successMsgs":[],"errorMsgs":[{"code":"POST_REPEAT_NAME","ent":{"orgAccountId":670869647114347,"id":3733289402804881262,"name":"JAVA组长","i18nNameId":null,"code":"Z010","createTime":1712024319068,"updateTime":1712024319068,"sortId":null,"isDeleted":false,"enabled":true,"externalType":0,"status":1,"description":"接口调研","customerProperties":[],"typeId":1,"valid":true,"entityType":"Post","fullName":"JAVA组长","dataI18nCategoryName":"organization.post.name","i18nNameWithLocale":"JAVA组长","realSortId":null,"preName":""},"msgInfo":null}],"errorMsgInfos":[{"code":null,"ent":{"orgAccountId":670869647114347,"id":3733289402804881262,"name":"JAVA组长","i18nNameId":null,"code":"Z010","createTime":1712024319068,"updateTime":1712024319068,"sortId":null,"isDeleted":false,"enabled":true,"externalType":0,"status":1,"description":"接口调研","customerProperties":[],"typeId":1,"valid":true,"entityType":"Post","fullName":"JAVA组长","dataI18nCategoryName":"organization.post.name","i18nNameWithLocale":"JAVA组长","realSortId":null,"preName":""},"msgInfo":"岗位名称重复，操作失败！"}],"success":false}
        //注：code可以重复
    }

    private static void synPosts(){

    }

    public class sysPost{




    }

}
